<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>字符串对象</title>
</head>
<body>
<div id="msg">
    <p></p>
</div>
<script>
    //定义方式
    var str1 = new String("abc");
    var str2 = "    abc ";

    //方法
    document.write(str1.length);
    document.write(str1.charAt(1));
    document.write(str1.trim());
    document.write(str1.lastIndexOf("c"));

    document.getElementById("msg").innerHTML="<p> str1.length = "+str1.length+"</p>";
    var strurl = "baidu.com"
    document.getElementById("msg").innerHTML="<p> str1.length = "+str1.length+"</p>";
    document.getElementById("msg").innerHTML="<p> str1.length = "+str1.length+"</p>";
</script>
</body>
</html>